import basegraphunit from './basegraphunit.js'
import coorPkg from '../../struct/coord.js'
import pathlink from '../../../graph/pathlink.js';

class PathInfo extends basegraphunit.BaseGraphUnit {
    constructor() {
        super();
        this.pos = new pathlink.PathCoordPos();


        //符号“$”隔开多个环，第一个环为外环；
        //符号“@”隔开环内的子图元
        //各子图元根据不同的类型有不同的描述方式
        //"line,x1,y1;x2,y2;....@arc,cntx,cnty,radius,stangle,endangle,anticlockwise@bezier,st,ctrlPt1,
        //ctrlPt2,end@quadratic,st,end,ctrlPt$line,x1,y1;x2,y2;....@arc,cntx,cnty,radius,stangle,endangle,anticlockwise"
        
        this.pathDesc = "";
    }

    translateSubInfo(tx,ty){
        this.x += tx;
        this.y += ty;
        this.pathDesc = this.pos.toString();
    }

    toJson() {
        var jsonobj = {};
        super.toJson(jsonobj);
        jsonobj["pathDesc"] = this.pathDesc;
        return jsonobj;
    }
    fromJson(obj) {
        super.fromJson(obj);
        this.pathDesc = obj["pathDesc"];
    }

    cloneCopy() {
        var pNewInfo = new PathInfo();
        super.cloneCopy(pNewInfo);
        pNewInfo.pathDesc = this.pathDesc;
        return pNewInfo;
    }
}

export default { PathInfo }